package com.tmt.wechat;

import java.util.concurrent.CompletableFuture;

import org.springframework.beans.factory.annotation.Autowired;

import com.swak.annotation.Context;
import com.swak.annotation.FluxService;
import com.swak.http.HttpService;
import com.swak.wechat.AbstractWechatService;
import com.swak.wechat.user.SessionToken;
import com.swak.wechat.user.SnsToken;

/**
 * 微信服务
 * 
 * @author lifeng
 */
@FluxService(context = Context.IO)
public class WechatService extends AbstractWechatService {

	@Autowired
	private HttpService httpService;
	@Autowired
	private WechatConfigImpl config;

	@Override
	public HttpService getHttpService() {
		return httpService;
	}

	/**
	 * 小程序登陆
	 * 
	 * @param code
	 * @return
	 */
	public CompletableFuture<SessionToken> oauth2Session(String code) {
		return super.oauth2Session(config, code);
	}

	/**
	 * 微信网页登陆
	 * 
	 * @param url   回调地址
	 * @param state 一个标识
	 * @return 封装之后的回调地址
	 */
	public CompletableFuture<String> toAuthorize(String url, String state) {
		return super.toAuthorize(config, url, state);
	}

	/**
	 * 微信网页登陆
	 * 
	 * @param code
	 * @param state
	 * @return
	 */
	public CompletableFuture<SnsToken> oauth2AccessToken(String code, String state) {
		return super.oauth2AccessToken(config, code, state);
	}
}
